import {Component, Input} from '@angular/core';

@Component({
  selector: 'app-rank-list',
  templateUrl: './rank-list.component.html',
  styleUrl: './rank-list.component.scss'
})
export class RankListComponent {
  @Input()
  headerTitle: string = '项目收益排名';
  @Input()
  unit: string = '元';
  @Input()
  public pgList: number[] = [2000, 1800, 1600, 1500, 1320, 1020, 960, 820, 800, 720];
  public pgListStyle: { percent: number, color: string }[] = [];

  constructor() {
    this.pgList.sort((a, b) => b - a)
    let color: string;
    for (let i = 0; i < this.pgList.length; i++) {
      if (i === 0) {
        color = '#95F204'
      } else if (i < 4) {
        color = '#00FFFF'
      } else if (i < 6) {
        color = '#F59A23'
      } else {
        color = '#D9001B'
      }
      this.pgListStyle.push({
        percent: this.pgList[i] / this.pgList[0],
        color: color
      });
    }
  }

  ngOnInit() {
  }
}
